<!DOCTYPE html>
<html>
<head>
    <% include ../include/css_header.html %>
    <link type="text/css" rel="stylesheet" href="/bootstrapSwitch.css" />
    <link type="text/css" rel="stylesheet" href="/user.css" />
</head>
<body class="user_bg">
    <div class="container">
        <% include ../include/top_bar.html %>
        <div class="row">
            <div class="col-xs-12" style="margin-top: 50px;height: 210px;">
                <img src="/img/<%=user.id %>" class="img-circle center-block" <%if(user.id === id){ %>id="headlogo"<%}%> style="border:5px solid rgba(255, 255, 255, 0.3)" onError="this.src='/fj_default_headimg.jpg';">
                <div class="user_name"><%=card.name %></div>
                <div class="company_name"><%=card.company %></div>
            </div>
        </div>
        <ul class="nav nav-tabs" role="tablist">
            <li class="active"><a href="#home" role="tab" data-toggle="tab">我的资料</a></li>
            <%if(user.id === id){%>
            <li><a href="#profile" role="tab" data-toggle="tab">圈子积分</a></li>
            <%}%>
        </ul>
        <div class="tab-content">
            <div class="tab-pane fade in active" id="home">
                <div class="row" style="background-color: #ffffff;min-height: 500px;">
                    <div class="col-xs-12" style="margin-top: 15px;">
                        <div class="well card_panel">
                            <div><label>公司：</label><%=card.company %></div>
                            <div><label>职位：</label><%=card.position %></div>
                            <div><label>电话：</label><strong style="color: #5BC0DE"><%=card.mobile %></strong></div>
                            <div><label>地址：</label><%=card.address %></div>
                            <div><label>Email：</label><%=card.email %></div>
                            <div><label>所在行业：</label><%=card.business %></div>
                            <div><label>产品/服务：</label><%=card.product %></div>
                        </div>
                    </div>
                    <% if(!isFriend){ %>
                    <div class="col-xs-12" style="">
                        <button type="button" class="btn btn-primary btn-block" id="receiveCard">收下名片，加入我的人脉</button>
                    </div>
                    <% }else if(id !== user.id){%>
                    <div class="col-xs-12">
                        <strong>Ta是我的</strong>
                    </div>
                    <div class="col-xs-12">
                        <%  var len = tag?tag.length:0;
                        if(len > 0){
                        for(var i=0; i< len; i++){
                        %>
                        <div class="rel_tag" data-val="<%=tag[i] %>"><%=tag[i] %></div>
                        <% } } %>
                        <div class="add_rel_tag">添加标签</div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="col-xs-12" style="margin-top: 30px;display: none;">
                        <strong>共同的圈子</strong>
                        <div id="samefaction" >
                        </div>
                    </div>
                    <div class="col-xs-12" style="margin-top: 30px;display: none;">
                        <strong>一起参加过</strong>
                        <div id="sameact">
                        </div>
                    </div>
                    <% }else if(id === user.id){%>
                    <div class="col-xs-12">
                        <button type="button" class="btn btn-primary btn-block" id="editCard">
                            <span class="icon-compose"></span>
                            <strong>编辑我的资料</strong>
                        </button>
                    </div>
                    <div class="col-xs-12" style="margin-top: 10px;">
                        <button type="button" class="btn btn-danger btn-block" id="setPrivacy">
                            <span class="icon-lock"></span>
                            <strong>设置我的隐私</strong>
                        </button>
                    </div>
                    <% } %>
                </div>
            </div>
            <%if(user.id === id){%>
            <div class="tab-pane fade" id="profile">
                <div class="row" style="min-height: 500px;padding: 15px;">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>我在的圈子</th>
                                <th>圈子积分</th>
                            </tr>
                        </thead>
                        <tbody>
                        <% if(fms.length > 0){
                              for(var i=0; i< fms.length; i++){
                                var fm = fms[i];
                        %>
                        <tr>
                            <td><%=i+1 %></td>
                            <td><a href="/faction/<%=fm.faction._id%>"><%=fm.faction.name%></a></td>
                            <td><label style="color:#F0AD4E"><%=fm.score%></label></td>
                        </tr>
                        <% } } %>
                        </tbody>
                    </table>
                </div>
            </div>
            <%}%>
        </div>
        <% include ../include/copyright.html %>
    </div>
    <div class="modal fade" id="newRelTag" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
                    <input class="form-control" type="text" value="" id="tagContent" placeholder="新标签"/>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-success" id="addBtn">添加</button>
                </div>
            </div>
        </div>
    </div>
    <% include ../include/slide_menu.html %>
    <% include ../include/js_footer.html %>
    <script src="<%=_locals.static_js_path %>/user.js"></script>
    <script type="text/javascript">
        var userId = '<%=user.id %>';
        var meId = '<%=id %>';
        var cardId = '<%=card.id %>';
        var isfriend = '<%=isFriend %>';
        var shareData = {
            img_url: siteGlobal.SITE_HOST+'/img/'+userId,
            link: siteGlobal.SITE_HOST+'/user/'+userId,
            title: '<%=card.name %>的名片',
            desc: '<%=card.company %> <%=card.position %> <%=card.name %>'
        }
        var tags = {};
        $(function(){
            WeixinUtil.initConfig(['onMenuShareTimeline', 'onMenuShareAppMessage'], true, function(){
                WeixinUtil.sharePage(shareData.title, shareData.desc, shareData.img_url, shareData.link)
            })
        })
    </script>
</body>
</html>